﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTC.Model;
using Common.Helper;
using System.Data;

namespace DTC.DAL
{
    public class DisplaysService
    {
        static string connectionString = string.Format("Data Source ={0}/Config/Config.db", AppDomain.CurrentDomain.BaseDirectory);
        public static List<Display> getDisplaysbyName(string name)
        {
            try
            {
                string sql =string.Format("select * from DISPLAY WHERE NAME='{0}'",name) ;
                DataSet ds = SQLiteHelper.ExecuteDataSet(connectionString, sql, null);
                List<Display> diss = new List<Display>();
                if (ds.Tables.Count > 0)
                {
                    DataTable dt = ds.Tables[0];
                    foreach (DataRow row in dt.Rows)
                    {
                        Display dp = new Display();
                        dp.MULTIPLE = row["MULTIPLE"].ToString();
                        dp.NAME = row["NAME"].ToString();
                        dp.SUBNAME = row["SUBNAME"].ToString();
                        dp.SUBNAME2 = row["SUBNAME2"].ToString();
                        dp.UNIT = row["UNIT"].ToString();
                        dp.ID = int.Parse(row["ID"].ToString());
                        diss.Add(dp);
                    }
                    return diss;
                }
                else
                    return null;
            }
            catch (Exception)
            {
                
                throw;
            }
        }
    }
}
